<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<script type="text/javascript">
// name space for this page
var p00_cust_add = {
	mid : "${menuId}",
	focusId : "p00_cust_add_mobile"
};

// Auto fill Addr
p00_cust_add.autoFillAddr = function() {
	var t1 = Ext.getCmp("p00_cust_add_svc_locate_id").getRawValue();
	var t2 = Ext.getCmp("p00_cust_add_park_space").getValue();
	Ext.getCmp("p00_cust_add_addr").setValue(t1 + " " + t2);
};

// add Panel
p00_cust_add.addPanel = Ext.create("Ext.form.Panel", {
	region : "center",
	buttonAlign : "left",
	frame : true,
	bodyPadding : 5,
	defaults : {
		xtype : "fieldset",
		layout : "anchor",
		defaults : {
			anchor : "100%",
			layout : "hbox",
			defaultType : "textfield",
			padding : "2 0",
			defaults : {
				labelAlign : "left",
				labelWidth : 120,
				width : 280,
				labelStyle : "padding-left: 15px"
			}
		}
	},
	items : [ {
		title : "基本信息",
		items : [ {
			xtype : "container",
			items : [ {
				id : "p00_cust_add_mobile",
				fieldLabel : "手机号码",
				name : "mobile",
				allowBlank : false
			}, {
				fieldLabel : "车牌号码",
				name : "car_id",
				allowBlank : false
			} ]
		}, {
			xtype : "container",
			items : [ {
				fieldLabel : "姓名",
				name : "name",
				allowBlank : false
			}, {
				fieldLabel : "性别",
				name : "gender",
				xtype : "uXcombo",
				comboOpts : {
					comboId : crm.consts.CDD_CD0001
				},
				labelWidth : 120,
				width : 280
			} ]
		} ]
	}, {
		title : "服务信息",
		items : [ {
			xtype : "container",
			layout : "vbox",
			items : [ {
				fieldLabel : "会员卡号",
				name : "member_id"
			}, {
				fieldLabel : "所属服务点",
				id: "p00_cust_add_svc_locate_id",
				name : "svc_locate_id",
				xtype : "uXcombo",
				comboOpts : {
					comboId : crm.consts.CDD_CD0009
				},
				labelWidth : 120,
				width : 280,
				listeners: {
                    change: {
                        fn: function(cbx, newvalue, oldvalue, opts) {
                            p00_cust_add.autoFillAddr();
                        }
                    }
                }
			}, {
				fieldLabel : "默认车位",
				name : "park_space",
				id: "p00_cust_add_park_space",
				width : 500,
				enableKeyEvents: true,
				listeners: {
                    keyup: {
                        fn: function(text, evt, opts) {
                        	p00_cust_add.autoFillAddr();
                        }
                    }
                }
			} ]
		} ]
	}, {
		title : "汽车信息",
		items : [ {
			xtype : "container",
			layout : "vbox",
			items : [ {
				xtype : "uXcombo",
				fieldLabel : "品牌",
				name : "car_brand",
				comboOpts : {
					comboId : crm.consts.CDD_CARBRAND
				},
				labelWidth : 120,
				width : 280
			}, {
				fieldLabel : "颜色",
				name : "car_color",
				xtype : "uXcombo",
				comboOpts : {
					comboId : crm.consts.CDD_CD0008
				},
				labelWidth : 120,
				width : 280
			}, {
				xtype : "uXcombo",
				name : "car_size_type",
				comboOpts : {
					comboId : crm.consts.CDD_CD0002
				},
				fieldLabel : "车体类型",
				labelWidth : 120,
				width : 280
			} ]
		} ]
	}, {
		title : "联系方式",
		items : [ {
			xtype : "container",
			layout : "vbox",
			items : [ {
				fieldLabel : "备用电话",
				name : "phone1"
			}, {
				fieldLabel : "QQ号码",
				name : "qq"
			}, {
				fieldLabel : "常用地址",
				id: "p00_cust_add_addr",
				width : 500,
				name : "addr"
			}, {
				fieldLabel : "备用地址",
				width : 500,
				name : "addr1"
			} ]
		} ]
	}, {
		xtype : "container",
		frame : true,
		layout : "anchor",
		margin : "10 0",
		items : [ {
			xtype : "container",
			defaults : {
				xtype : "button",
				style : "margin-right: 5px; padding: 2px 20px"
			},
			items : [ {
				text : "重置",
				handler : function() {
					this.up("form").getForm().reset();
					Ext.getCmp(p00_cust_add.focusId).focus();
				}
			}, {
				text : "保存",
				handler : function() {
					this.up("form").getForm().submit({
						url : "cust/add.shtm",
						success : function(form, action) {
							if (action.result.success == "true") {
								Ext.Msg.alert("信息提示", "保存成功");
								form.reset();
							} else {
			                    Ext.Msg.alert("提示信息", action.result.errorMsgs);
			                }
						},
						faliure : function(form, action) {
							Ext.Msg.alert("提示信息", action.result.errorMsgs);
						}
					});
				}
			} ]
		} ]
	} ]
});

//show tab content
p00_cust_add.items = [ p00_cust_add.addPanel ];
crm.utils.showTabContent(p00_cust_add);

</script>

